using Microsoft.Xna.Framework.Graphics;

namespace SolarWinds.Helpers
{
    class SpriteFontHelper
    {
        public static string StripString(SpriteFont font, string text, float width)
        {
            const string strDots = "...";
            
            float textWidth = font.MeasureString(text).X;
            if (textWidth < width) return text;

            while (textWidth > width)
            {
                if (text.Length == 0) break;

                text = text.Substring(0, text.Length -1);

                textWidth = font.MeasureString(text + strDots).X;
            }

            return text + strDots;
        }
    }
}